// 计算状态栏和胶囊区的高度
import {
	onMounted,
	ref
} from 'vue'

export function useSystemInfo() {
	//状态栏高度
	const statusHeight = ref(0)
	//胶囊区高度
	const capsuleZoneHeight = ref(0)

	//获取状态栏和胶囊区高度的函数
	const getStatusAndCapsuleZoneHeight = async () => {
		let systemInfo = uni.getSystemInfoSync()
		statusHeight.value = systemInfo.statusBarHeight
		const menuButton = uni.getMenuButtonBoundingClientRect();
		capsuleZoneHeight.value = menuButton.height + (menuButton.top - statusHeight.value);
	}
	onMounted(() => {
		getStatusAndCapsuleZoneHeight()
	})
	return {
		statusHeight,
		capsuleZoneHeight
	}
}